package com.wyh.utils.sqlUtils.user;

import com.wyh.entity.Account;

public class updateUserSqlDynamic {
    public String updateDynamic(Account user) {
        StringBuilder sql = new StringBuilder();
        sql.append("UPDATE user SET ");
        if (user.getName() != null) {
            sql.append("name = #{name}, ");
        }
        if (user.getEmail() != null) {
            sql.append("email = #{email}, ");
        }
        if (user.getTelephoneNumber() != null) {
            sql.append("telephoneNumber = #{telephoneNumber}, ");
        }
        if (user.getCN_ID() != null) {
            sql.append("CN_ID = #{CN_ID}, ");
        }
        if (user.getPermission()!=null) {
            sql.append("permission = #{permission}, ");
        }
        if (user.getGender()!=null) {
            sql.append(" gender = #{gender}, ");
        }
        if (user.getRemark()!=null) {
            sql.append("remark = #{remark}, ");
        }
        if (user.getUsername()!=null) {
            sql.append("Username = #{username}, ");
        }
        if (user.getPassword()!=null) {
            sql.append("password = #{password} ");
        }

        sql.append("WHERE uid = #{Uid};");
        System.out.println(sql);
        return sql.toString();
    }
}
